<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.9.1"/>
<title>RaftLib: map.hpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { init_search(); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">RaftLib
   &#160;<span id="projectnumber">0.3a</span>
   </div>
   <div id="projectbrief">C++ Stream Processing Template Library</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.9.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">map.hpp</div>  </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;</div>
<div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;<span class="preprocessor">#ifndef _MAP_HPP_</span></div>
<div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;<span class="preprocessor">#define _MAP_HPP_  1</span></div>
<div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;<span class="preprocessor">#include &lt;typeinfo&gt;</span></div>
<div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;<span class="preprocessor">#include &lt;cassert&gt;</span></div>
<div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;<span class="preprocessor">#include &lt;cxxabi.h&gt;</span></div>
<div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;<span class="preprocessor">#include &lt;thread&gt;</span></div>
<div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;<span class="preprocessor">#include &lt;sstream&gt;</span></div>
<div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;</div>
<div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;<span class="preprocessor">#include &quot;kernelkeeper.tcc&quot;</span></div>
<div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;<span class="preprocessor">#include &quot;portexception.hpp&quot;</span></div>
<div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;<span class="preprocessor">#include &quot;schedule.hpp&quot;</span></div>
<div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;<span class="preprocessor">#include &quot;simpleschedule.hpp&quot;</span></div>
<div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;<span class="preprocessor">#include &quot;kernel.hpp&quot;</span></div>
<div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;<span class="preprocessor">#include &quot;port_info.hpp&quot;</span></div>
<div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;<span class="preprocessor">#include &quot;allocate.hpp&quot;</span></div>
<div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;<span class="preprocessor">#include &quot;dynalloc.hpp&quot;</span></div>
<div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;<span class="preprocessor">#include &quot;stdalloc.hpp&quot;</span></div>
<div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;<span class="preprocessor">#include &quot;mapbase.hpp&quot;</span></div>
<div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;<span class="preprocessor">#include &quot;poolschedule.hpp&quot;</span></div>
<div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;<span class="preprocessor">#include &quot;basicparallel.hpp&quot;</span></div>
<div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;<span class="preprocessor">#include &quot;noparallel.hpp&quot;</span></div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;<span class="preprocessor">#include &quot;Clock.hpp&quot;</span></div>
<div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;<span class="preprocessor">#include &quot;SystemClock.tcc&quot;</span></div>
<div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;</div>
<div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;<span class="keyword">extern</span> <a class="code" href="class_clock.html">Clock</a> *system_clock;</div>
<div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;</div>
<div class="line"><a name="l00047"></a><span class="lineno"><a class="line" href="class_map.html">   47</a></span>&#160;<span class="keyword">class </span><a class="code" href="class_map.html">Map</a> : <span class="keyword">public</span> <a class="code" href="class_map_base.html">MapBase</a></div>
<div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;{</div>
<div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;   <a class="code" href="class_map.html#a0f5ad0fd4563497b4214038cbca8b582">Map</a>();</div>
<div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;   <span class="keyword">virtual</span> <a class="code" href="class_map.html#aa403fbe09394ccf39747588f5168e3b2">~Map</a>();</div>
<div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;   </div>
<div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;   <span class="keyword">template</span>&lt; <span class="keyword">class </span>scheduler           = <a class="code" href="classsimple__schedule.html">simple_schedule</a>, </div>
<div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;             <span class="keyword">class </span>allocator           = <a class="code" href="classdynalloc.html">dynalloc</a>,</div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;             <span class="keyword">class </span>parallelism_monitor = <a class="code" href="classbasic__parallel.html">basic_parallel</a> &gt; </div>
<div class="line"><a name="l00069"></a><span class="lineno"><a class="line" href="class_map.html#ad875bad2283446bfeed2f69752984c2d">   69</a></span>&#160;      <span class="keywordtype">void</span> <a class="code" href="class_map.html#ad875bad2283446bfeed2f69752984c2d">exe</a>()</div>
<div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;   {</div>
<div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;      <span class="keywordflow">for</span>( <span class="keyword">auto</span> * <span class="keyword">const</span> <a class="code" href="classsubmap.html">submap</a> : <a class="code" href="class_map_base.html#abc4856ed552e77510211851f0a4a02ab">sub_maps</a> )</div>
<div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;      {</div>
<div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;         <span class="keyword">auto</span> &amp;container( <a class="code" href="class_map_base.html#a2220cd630c5d00708f08d9bc70a48220">all_kernels</a>.acquire() );</div>
<div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;         <span class="keyword">auto</span> &amp;subcontainer( <a class="code" href="classsubmap.html">submap</a>-&gt;<a class="code" href="class_map_base.html#a2220cd630c5d00708f08d9bc70a48220">all_kernels</a>.acquire() );  </div>
<div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;         container.insert( subcontainer.begin(),</div>
<div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;                           subcontainer.end()   );</div>
<div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;         <a class="code" href="class_map_base.html#a2220cd630c5d00708f08d9bc70a48220">all_kernels</a>.release();</div>
<div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;         <a class="code" href="classsubmap.html">submap</a>-&gt;<a class="code" href="class_map_base.html#a2220cd630c5d00708f08d9bc70a48220">all_kernels</a>.release();</div>
<div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;      }</div>
<div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;      <a class="code" href="class_map.html#adcaba5f11ec1b7fef29a0a1e62632373">checkEdges</a>( <a class="code" href="class_map_base.html#a2541cb37a237e66fc88129f9f0b02f50">source_kernels</a> );</div>
<div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;      <span class="comment">//enableDuplication( source_kernels, all_kernels );</span></div>
<div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;      <span class="keyword">volatile</span> <span class="keywordtype">bool</span> exit_alloc( <span class="keyword">false</span> );</div>
<div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;      allocator alloc( (*<span class="keyword">this</span>), exit_alloc );</div>
<div class="line"><a name="l00087"></a><span class="lineno">   87</span>&#160;      std::thread mem_thread( [&amp;](){</div>
<div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;         alloc.run();</div>
<div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;      });</div>
<div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;     </div>
<div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;      alloc.waitTillReady();</div>
<div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160;</div>
<div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;      scheduler sched( (*<span class="keyword">this</span>) );</div>
<div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;      sched.init();</div>
<div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;      </div>
<div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160;      std::thread sched_thread( [&amp;](){</div>
<div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;         sched.start();</div>
<div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;      });</div>
<div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;</div>
<div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;      <span class="keyword">volatile</span> <span class="keywordtype">bool</span> exit_para( <span class="keyword">false</span> );</div>
<div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160;      parallelism_monitor pm( (*<span class="keyword">this</span>)     , </div>
<div class="line"><a name="l00104"></a><span class="lineno">  104</span>&#160;                              alloc       ,</div>
<div class="line"><a name="l00105"></a><span class="lineno">  105</span>&#160;                              sched       ,</div>
<div class="line"><a name="l00106"></a><span class="lineno">  106</span>&#160;                              exit_para   );</div>
<div class="line"><a name="l00107"></a><span class="lineno">  107</span>&#160;      std::thread parallel_mon( [&amp;](){</div>
<div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;         pm.start();</div>
<div class="line"><a name="l00109"></a><span class="lineno">  109</span>&#160;      });</div>
<div class="line"><a name="l00111"></a><span class="lineno">  111</span>&#160;      sched_thread.join();</div>
<div class="line"><a name="l00112"></a><span class="lineno">  112</span>&#160;</div>
<div class="line"><a name="l00114"></a><span class="lineno">  114</span>&#160;      exit_alloc = <span class="keyword">true</span>;</div>
<div class="line"><a name="l00115"></a><span class="lineno">  115</span>&#160;      mem_thread.join();</div>
<div class="line"><a name="l00117"></a><span class="lineno">  117</span>&#160;      exit_para = <span class="keyword">true</span>;</div>
<div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;      parallel_mon.join();</div>
<div class="line"><a name="l00119"></a><span class="lineno">  119</span>&#160;</div>
<div class="line"><a name="l00121"></a><span class="lineno">  121</span>&#160;      <span class="keywordflow">return</span>; </div>
<div class="line"><a name="l00122"></a><span class="lineno">  122</span>&#160;   }</div>
<div class="line"><a name="l00123"></a><span class="lineno">  123</span>&#160;</div>
<div class="line"><a name="l00124"></a><span class="lineno">  124</span>&#160;</div>
<div class="line"><a name="l00125"></a><span class="lineno">  125</span>&#160;<span class="keyword">protected</span>:</div>
<div class="line"><a name="l00126"></a><span class="lineno">  126</span>&#160;</div>
<div class="line"><a name="l00133"></a><span class="lineno">  133</span>&#160;   <span class="keywordtype">void</span> <a class="code" href="class_map.html#adcaba5f11ec1b7fef29a0a1e62632373">checkEdges</a>( kernelkeeper &amp;source_k );</div>
<div class="line"><a name="l00134"></a><span class="lineno">  134</span>&#160;</div>
<div class="line"><a name="l00142"></a><span class="lineno">  142</span>&#160;   <span class="keywordtype">void</span> <a class="code" href="class_map.html#aa8673192361b2e519e1c85bb0935e708">enableDuplication</a>( kernelkeeper &amp;source, kernelkeeper &amp;all );</div>
<div class="line"><a name="l00143"></a><span class="lineno">  143</span>&#160;</div>
<div class="line"><a name="l00144"></a><span class="lineno">  144</span>&#160;</div>
<div class="line"><a name="l00149"></a><span class="lineno"><a class="line" href="class_map.html#a901ac6fe1c35f3c114cf9e83f75dde0c">  149</a></span>&#160;   <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classbasic__parallel.html">basic_parallel</a>;</div>
<div class="line"><a name="l00150"></a><span class="lineno">  150</span>&#160;   <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="class_schedule.html">Schedule</a>;</div>
<div class="line"><a name="l00151"></a><span class="lineno">  151</span>&#160;   <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="class_allocate.html">Allocate</a>;</div>
<div class="line"><a name="l00152"></a><span class="lineno">  152</span>&#160;</div>
<div class="line"><a name="l00153"></a><span class="lineno">  153</span>&#160;};</div>
<div class="line"><a name="l00154"></a><span class="lineno">  154</span>&#160;</div>
<div class="line"><a name="l00155"></a><span class="lineno">  155</span>&#160;<span class="preprocessor">#endif </span><span class="comment">/* END _MAP_HPP_ */</span><span class="preprocessor"></span></div>
<div class="ttc" id="classbasic__parallel_html"><div class="ttname"><a href="classbasic__parallel.html">basic_parallel</a></div><div class="ttdef"><b>Definition:</b> basicparallel.hpp:48</div></div>
<div class="ttc" id="class_map_base_html"><div class="ttname"><a href="class_map_base.html">MapBase</a></div><div class="ttdef"><b>Definition:</b> mapbase.hpp:100</div></div>
<div class="ttc" id="class_map_base_html_a2220cd630c5d00708f08d9bc70a48220"><div class="ttname"><a href="class_map_base.html#a2220cd630c5d00708f08d9bc70a48220">MapBase::all_kernels</a></div><div class="ttdeci">kernelkeeper all_kernels</div><div class="ttdef"><b>Definition:</b> mapbase.hpp:422</div></div>
<div class="ttc" id="class_clock_html"><div class="ttname"><a href="class_clock.html">Clock</a></div><div class="ttdef"><b>Definition:</b> Clock.hpp:31</div></div>
<div class="ttc" id="classsubmap_html"><div class="ttname"><a href="classsubmap.html">submap</a></div><div class="ttdef"><b>Definition:</b> submap.hpp:34</div></div>
<div class="ttc" id="classsimple__schedule_html"><div class="ttname"><a href="classsimple__schedule.html">simple_schedule</a></div><div class="ttdef"><b>Definition:</b> simpleschedule.hpp:30</div></div>
<div class="ttc" id="class_map_html_aa403fbe09394ccf39747588f5168e3b2"><div class="ttname"><a href="class_map.html#aa403fbe09394ccf39747588f5168e3b2">Map::~Map</a></div><div class="ttdeci">virtual ~Map()</div><div class="ttdef"><b>Definition:</b> map.cpp:40</div></div>
<div class="ttc" id="class_map_html_adcaba5f11ec1b7fef29a0a1e62632373"><div class="ttname"><a href="class_map.html#adcaba5f11ec1b7fef29a0a1e62632373">Map::checkEdges</a></div><div class="ttdeci">void checkEdges(kernelkeeper &amp;source_k)</div><div class="ttdef"><b>Definition:</b> map.cpp:45</div></div>
<div class="ttc" id="class_map_base_html_abc4856ed552e77510211851f0a4a02ab"><div class="ttname"><a href="class_map_base.html#abc4856ed552e77510211851f0a4a02ab">MapBase::sub_maps</a></div><div class="ttdeci">std::vector&lt; MapBase * &gt; sub_maps</div><div class="ttdef"><b>Definition:</b> mapbase.hpp:429</div></div>
<div class="ttc" id="classdynalloc_html"><div class="ttname"><a href="classdynalloc.html">dynalloc</a></div><div class="ttdef"><b>Definition:</b> dynalloc.hpp:25</div></div>
<div class="ttc" id="class_map_html"><div class="ttname"><a href="class_map.html">Map</a></div><div class="ttdef"><b>Definition:</b> map.hpp:47</div></div>
<div class="ttc" id="class_map_base_html_a2541cb37a237e66fc88129f9f0b02f50"><div class="ttname"><a href="class_map_base.html#a2541cb37a237e66fc88129f9f0b02f50">MapBase::source_kernels</a></div><div class="ttdeci">kernelkeeper source_kernels</div><div class="ttdef"><b>Definition:</b> mapbase.hpp:418</div></div>
<div class="ttc" id="class_allocate_html"><div class="ttname"><a href="class_allocate.html">Allocate</a></div><div class="ttdef"><b>Definition:</b> allocate.hpp:54</div></div>
<div class="ttc" id="class_map_html_a0f5ad0fd4563497b4214038cbca8b582"><div class="ttname"><a href="class_map.html#a0f5ad0fd4563497b4214038cbca8b582">Map::Map</a></div><div class="ttdeci">Map()</div><div class="ttdef"><b>Definition:</b> map.cpp:35</div></div>
<div class="ttc" id="class_schedule_html"><div class="ttname"><a href="class_schedule.html">Schedule</a></div><div class="ttdef"><b>Definition:</b> schedule.hpp:34</div></div>
<div class="ttc" id="class_map_html_ad875bad2283446bfeed2f69752984c2d"><div class="ttname"><a href="class_map.html#ad875bad2283446bfeed2f69752984c2d">Map::exe</a></div><div class="ttdeci">void exe()</div><div class="ttdef"><b>Definition:</b> map.hpp:69</div></div>
<div class="ttc" id="class_map_html_aa8673192361b2e519e1c85bb0935e708"><div class="ttname"><a href="class_map.html#aa8673192361b2e519e1c85bb0935e708">Map::enableDuplication</a></div><div class="ttdeci">void enableDuplication(kernelkeeper &amp;source, kernelkeeper &amp;all)</div><div class="ttdef"><b>Definition:</b> map.cpp:68</div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Mon Oct 12 2015 12:16:50 for RaftLib by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.9.1
</small></address>
</body>
</html>
